package com.zhuang.interpreter;

/**
 * @Classname Client
 * @Description 解释权模式 测试类
 * @Date 2021/3/31 9:46
 * @Created by dell
 */

public class Client {
    public static void main(String[] args) {
        Context context = new Context();

        Variable a = new Variable("a");
        Variable b = new Variable("b");
        Variable c = new Variable("c");
        Variable d = new Variable("d");
        Variable e = new Variable("e");

        context.assign(a, 2);
        context.assign(b, 3);
        context.assign(c, 4);
        context.assign(d, 5);
        context.assign(e, 6);

        AbstractExpression expression = new Minus(new Plus(new Plus(new Plus(a, b), c), d), e);

        System.out.println(expression + "=" + expression.interpret(context));
    }
}
